from selenium.webdriver.common.by import By


class  AdminNotificationTemplateLocator:

    #notification tempalate菜单
    notification_tempalate_tab = (By.CSS_SELECTOR, '[path="/console/messageCenter/template"]')

    #搜索框
    search_box = (By.ID,"messageTemplateName")

    #搜索按钮
    search_button = (By.XPATH,'//button[contains(@class,"antd4-input-search-button")]')

    #刷新按钮
    refresh_button = (By.XPATH, '(//button[contains(@class,"antd4-btn-default")])[2]')

    #第一条模板id
    first_template_id = (By.XPATH, '(//div[contains(@class,"cre-table-nowrap")])[1]')
    #第一条模板名称————用于公告
    announcement_first_template_name = (By.XPATH,'//*[@class="antd4-table-tbody"]/tr[2]/td/a')
    #第一条模板des
    first_template_des = (By.XPATH, '(//div[contains(@class,"cre-table-nowrap")])[1]')
    #第一条模板名称 -- 普通模板
    frist_template_name = (By.XPATH,'//*[@class="antd4-table-tbody"]/tr[contains(@class,"antd4-table-row")][1]/td[1]')

    #第一条公告模板Edit按钮
    announcement_edit_button = (By.XPATH, '(//button[contains(@class,"antd4-btn-link")])[1]')
    # 触发编辑按钮
    move_action = (By.XPATH,'(//*[@aria-label="ellipsis"])[1]')
    #第一条公告模板Send按钮
    announcement_send_button = (By.XPATH, '//*[text()="Send"]')
    #三个公告模板类型
    first_announcement_type = (By.XPATH, '//*[@class="antd4-table-tbody"]/tr[2]/td[4]')
    second_announcement_type = (By.XPATH, '//*[@class="antd4-table-tbody"]/tr[3]/td[4]')
    third_announcement_type = (By.XPATH, '//*[@class="antd4-table-tbody"]/tr[4]/td[4]')

    #公告模板编辑界面
    #id
    eidt_id = (By.ID,'messageTemplateOpenId')

    #name
    eidt_name = (By.ID,'messageTemplateName')
    edit_name_error = (By.XPATH,'(//div[contains(@class,"antd4-form-item-explain-error")])[1]')
    #description
    edit_des = (By.ID,'remark')
    #notification title
    edit_title = (By.ID,'messageTitle')
    edit_title_error = (By.XPATH, '(//div[contains(@class,"antd4-form-item-explain-error")])[2]')
    #notification type
    notification_type = (By.XPATH,'(//div[contains(@class,"antd4-select-selector")])[1]')
    #background
    background = (By.XPATH,'(//div[contains(@class,"antd4-select-selector")])[2]')
    background_value = (By.CSS_SELECTOR,'[title="Normal"]')
    #channel
    channel_label_sms = (By.XPATH,'(//label[contains(@class,"antd4-checkbox-wrapper-in-form-item")])[1]')
    channel_label_email = (By.XPATH,'(//label[contains(@class,"antd4-checkbox-wrapper-in-form-item")])[2]')
    channel_label_internal = (By.XPATH,'(//label[contains(@class,"antd4-checkbox-wrapper-in-form-item")])[3]')
    #sms
    sms_collapse = (By.XPATH,'(//div[contains(@class,"antd4-collapse-header")])[1]')
    sms_content = (By.ID,'messageTemplateInstanceList_0_messageContent')
    #email
    email_collapse = (By.XPATH, '(//div[contains(@class,"antd4-collapse-header")])[2]')
    #email_content = (By.ID, 'w-e-textarea-5')
    email_content = (By.XPATH,'(//*[@data-slate-node="element"]/span/span/span)[1]')
    #internal notification
    internal_collapse = (By.XPATH, '(//div[contains(@class,"antd4-collapse-item")])[3]')
    #internal_content = (By.ID, 'w-e-textarea-6')
    internal_content = (By.XPATH, '(//*[@data-slate-node="element"]/span/span/span)[2]')
    #submit按钮
    submit_button = (By.XPATH, '//button[contains(@class,"antd4-btn-primary")]')

    #发送公告页面
    #Select Receiver
    select_by_user_type = (By.XPATH, '(//input[contains(@class,"antd4-radio-input")])[1]')
    #search_specific_user = (By.XPATH, '(//input[contains(@class,"antd4-radio-input")])[2]')
    search_specific_user = (By.XPATH, '(//label[contains(@class,"antd4-radio-wrapper-in-form-item")])[2]')

    select_user = (By.XPATH, '//*[@id="creForm"]/div[2]/div[2]/div[1]/div/div')
    select_user_input = (By.XPATH,'//*[@id="creForm_user"]')
    select_user_type = (By.XPATH,'/html/body/div[7]/div/div[2]/div/div/div[2]/div/form/div[2]/div[2]/div[1]/div/div')

    def get_select_user_value(self,email):
        select_user_value = (By.CSS_SELECTOR,'[title="%s"]'%email)
        return select_user_value

    select_user_type_value = (By.CSS_SELECTOR,'[title="Enterprise"]')
    #Send Time
    send_time_immediately = (By.XPATH, '(//input[contains(@class,"antd4-radio-input")])[3]')
    send_time_specific_send_time = (By.XPATH, '(//input[contains(@class,"antd4-radio-input")])[4]')

    #Expiration Time
    expriation_time = (By.ID,"creForm_expirationTime")
    #确认发送按钮
    send_ok_button = (By.XPATH, '//button[contains(@class,"antd4-btn-primary")]')

    #公告详情页
    send_history_tab =  (By.XPATH, '(//div[contains(@class,"antd4-tabs-tab-btn")])[2]')
    last_receiver_list = (By.XPATH,'/html/body/div[1]/section/section/main/div/div/div/div/div[3]/div/div/div[4]/div/div[2]/div/div[2]/div/div/div/div/div/div/table/tbody/tr[2]/td[4]/button')
    #last_receiver_list = (By.XPATH, '(//button[contains(@class,"antd4-btn-link")])[1]')
    #接收人列表，第一个记录的email
    last_receiver_email = (By.XPATH,'/html/body/div[4]/div/div[2]/div/div/div[2]/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[2]/div')

    #announcement_detail_name = (By.XPATH,'//*[@id="root"]/section/section/main/div/div/div/div/div[3]/div/div/div[1]/div[2]/div[1]/div')
    announcement_detail_name = (By.XPATH,'//*[text()="Name"]/..//../span[2]')

    #announcement_detail_des = (By.XPATH,'//*[@id="root"]/section/section/main/div/div/div/div/div[3]/div/div/div[1]/div[2]/div[2]')
    announcement_detail_des = (By.XPATH,'//*[contains(@class,"baseInfo__left_bottom")]')


    #announcement_detail_type = (By.XPATH,'//*[@id="root"]/section/section/main/div/div/div/div/div[3]/div/div/div[3]/div[2]/div/div/table/tbody/tr/td[3]/div/span[2]')
    announcement_detail_type = (By.XPATH,'//*[text()="Notification Type"]/..//../span[2]')


    announcement_template_history_view_detail_button = (By.XPATH,'(//*[text()="View Detail"]/..)[1]')
    #编辑历史详情页
    history_detail_name = (By.XPATH,'//*[@class="antd4-drawer-wrapper-body"]//*[text()="Name"]/../span[2]')
    history_detail_des = (By.XPATH, '//*[@class="antd4-drawer-wrapper-body"]//*[text()="Description"]/../span[2]')
    history_detail_title = (By.XPATH, '//*[@class="antd4-drawer-wrapper-body"]//*[text()="Notification Title"]/../span[2]')
    history_detail_type = (By.XPATH, '//*[@class="antd4-drawer-wrapper-body"]//*[text()="Notification Type"]/../span[2]')
    history_detail_channel = (By.XPATH, '//*[@class="antd4-drawer-wrapper-body"]//*[text()="Channel"]/../span[2]')
    history_detail_backgroud = (By.XPATH, '//*[@class="antd4-drawer-wrapper-body"]//*[text()="Background"]/../span[2]')
    history_detail_SMS_Content = (By.XPATH, '//*[@class="antd4-drawer-wrapper-body"]//*[text()="SMS Content"]/../span[2]')
    history_detail_email_Content = (By.XPATH, '//*[@class="antd4-drawer-wrapper-body"]//*[text()="Email Content"]/../span[2]')
    history_detail_internal_Notification = (By.XPATH, '//*[@class="antd4-drawer-wrapper-body"]//*[text()="Internal Notification"]/../span[2]')


    #用户登录页面，查公告页面
    user_announcement_title = (By.XPATH,'//*[@id="rc_unique_1"]/div/div[1]')
    user_announcement_internal_content = (By.XPATH, '//*[@id="information"]/div[3]/div/div[2]/div/div[2]/div[2]/div[1]/div/div//div/div/div/table/tbody/tr[3]/td/div/p')

    #template 列表
    template_id = (By.XPATH,'//*[@id="root"]/section/section/main/div/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/thead/tr/th[1]')
    template_name = (By.XPATH,'//*[text()="Name"]')
    template_des = (By.XPATH,'//*[text()="Description"]')
    template_notification_type =(By.XPATH,'//*[text()="Notification Type"]')
    template_create_time =(By.XPATH,'//*[contains(text(),"Creation Time")]')

    total_count = (By.XPATH,'//*[@class="antd4-pagination-total-text"]')

    #编辑通知模板
    first_collapse = (By.XPATH, '(//div[contains(@class,"antd4-collapse-header")])[1]')
    first_content = (By.XPATH, '(//*[@data-slate-node="text"]/span/span)[1]')

